package user

import (
	"context"

	"github.com/gogf/gf/v2/util/gconv"

	v1 "gf-xb-api/api/user/v1"
	"gf-xb-api/internal/consts"
	"gf-xb-api/internal/service"
)

func (c *ControllerV1) GetOne(ctx context.Context, req *v1.GetOneReq) (res *v1.GetOneRes, err error) {

	output, err := service.User().GetOne(ctx, req.Id)
	if err != nil {
		return nil, err
	}

	err = gconv.Struct(output, &res)
	if err != nil {
		return nil, err
	}

	res.StatusName = consts.UserStatus(res.Status).String()
	res.Timestamp = output.UpdatedAt.TimestampMilli()

	return
}
